const blockquote2 = {
    type: 'blockquote2',
    children: [{ text: '' }]
}
const blockquote3 = {
    type: 'blockquote3',
    children: [{ text: '' }]
}

function renderBlockquote2(elem, children, editor) {
    console.log(children)
    const iconVnode = h(
        // HTML tag
        'blockquote',
        // HTML 属性
        {
            props: { class: "Blockquote2" }, // HTML 属性，驼峰式写法
            style: { backgroundColor: '#D8D8D8', borderLeft: 'none', fontSize: "17px" /* 其他... */ } // HTML style ，驼峰式写法
        },
        children
    )
    const divVnode = h(
        'div',
        {
            props: {}, // HTML 属性，驼峰式写法
            style: {} // HTML style ，驼峰式写法
        },
        [iconVnode]
    )
    return divVnode;
}

function renderBlockquote3(elem, children, editor) {
    console.log(children)
    const iconVnode = h(
        // HTML tag
        'blockquote',
        // HTML 属性
        {
            props: { class: "Blockquote3" }, // HTML 属性，驼峰式写法
            style: {
                backgroundSize: 'contain',
                paddingLeft: '0',
                paddingBottom:'0',
                backgroundRepeat:'no-repeat', backgroundImage: `url('${'https://resource.shalou.net/admin/2025/JULY/7/11/47/3841a393-cd58-4cab-9a64-48019184f938.png'}')`, backgroundColor: '#fff', borderLeft: 'none', fontSize: "17px", /* 其他... */
            } // HTML style ，驼峰式写法
        },
        children
    )
    const divVnode = h(
        'div',
        {
            props: {}, // HTML 属性，驼峰式写法
            style: {} // HTML style ，驼峰式写法
        },
        [iconVnode]
    )
    return divVnode;
}

function blockquote2ToHtml(elem, childrenHtml) {

    // 生成 HTML 代码
    const html = `<blockquote
        class="blockquote2"
         style="background-color: rgb(216, 216, 216); border-left: none;"
          data-w-e-type="blockquote2"
      >${childrenHtml}</blockquote>`

    return html
}


function blockquote3ToHtml(elem, childrenHtml) {

    // 生成 HTML 代码
    const html = `<blockquote
        class="blockquote3"
         style="background-color: rgb(216, 216, 216); border-left: none;"
          data-w-e-type="blockquote3"
      >${childrenHtml}</blockquote>`

    return html
}



const elemToblockquote2HtmlConf = {
    type: 'blockquote2', // 新元素的 type ，重要！！！
    elemToHtml: blockquote2ToHtml,
}
const renderBlockquote2ElemConf = {
    type: 'blockquote2', // 新元素 type ，重要！！！
    renderElem: renderBlockquote2,
}

const elemToblockquote3HtmlConf = {
    type: 'blockquote3', // 新元素的 type ，重要！！！
    elemToHtml: blockquote3ToHtml,
}
const renderBlockquote3ElemConf = {
    type: 'blockquote3', // 新元素 type ，重要！！！
    renderElem: renderBlockquote3,
}



function parseblockquote2Html(
    elem,
    children,
    editor) {
    const $elem = $(elem)
    children = children.filter(child => {
        if (typeof child == 'string') return true
        if (editor.isInline(child)) return true
        return false
    })

    // 无 children ，则用纯文本
    if (children.length === 0) {
        children = [{ text: $elem.text().replace(/\s+/gm, ' ') }]
    }

    return {
        type: 'blockquote2',
        // @ts-ignore
        children,
    }
}

const parseblockquote2HtmlConf = {
    selector: 'blockquote[blockquote2]', // data-w-e-type 属性，留给自定义元素，保证扩展性
    parseElemHtml: parseblockquote2Html,
}



function parseblockquote3Html(
    elem,
    children,
    editor) {
    const $elem = $(elem)
    children = children.filter(child => {
        if (typeof child == 'string') return true
        if (editor.isInline(child)) return true
        return false
    })

    // 无 children ，则用纯文本
    if (children.length === 0) {
        children = [{ text: $elem.text().replace(/\s+/gm, ' ') }]
    }

    return {
        type: 'blockquote3',
        // @ts-ignore
        children,
    }
}

const parseblockquote3HtmlConf = {
    selector: 'blockquote[blockquote3]', // data-w-e-type 属性，留给自定义元素，保证扩展性
    parseElemHtml: parseblockquote3Html,
}



function withBlockquote(editor) {
    const { insertBreak, insertText } = editor
    const newEditor = editor
    // 重写 insertBreak - 换行时插入 p


    // 返回 editor ，重要！
    return newEditor
}